<template>
  <!-- 首页 -->
  <div>
    <el-carousel indicator-position="none" style="overflow:hidden;">
      <el-carousel-item v-for="item in imgIdList" :key="item">
        <el-image :src="'http://101.43.223.224:8765/image/getImageById?id='+item"></el-image>
      </el-carousel-item>
    </el-carousel>
    <el-row>
      <el-col :span="24"><div style="font-size: 30px;margin-left: 20px;text-align: center;margin-top:10px; ;color:gray">热门拍卖</div></el-col>
    </el-row>
    <div class="hot_material_transaction">
      <div class="div1" v-for="(goods,index) in goodsList" :key="index">
          <div style="width:290px;height:200px;text-align: center;overflow:hidden;">
            <el-image class="img" :src="'http://101.43.223.224:8765/image/getImageById?id='+goods.imgId" @click="toNoBiddingDetailsPage(goods)"></el-image>
          </div>
          <div style="position: relative; top: -29px; color: white; background-color: #BA0000;opacity: 0.3;height: 40px;line-height: 40px;">
            <div style="height: 40px;width:238px;float:left;margin-left:10px;font-size: 16px;">{{goods.goodsName}}</div>
            <img style="width: 40px;height:40px;float: right;" src="../assets/dongtai.gif">
          </div>
          <div style="width: 312px;margin-left: 17px;height: 53px;margin-top: -30px;">
            <!-- <span class="begin_in_a_minute" v-show="goods.transactionStatus === 1" style="background-color: #008000;border-radius: 40%;">未开始</span>
            <span class="begin_in_a_minute" v-show="goods.transactionStatus === 2" style="background-color: #FF6633;border-radius: 40%;">进行中</span>
            <span class="begin_in_a_minute" v-show="goods.transactionStatus === 3" style="background-color: #999999;border-radius: 40%;">已结束</span> -->
            <span style="position: relative;top: -34px;left:-10px;" v-if="goods.transactionStatus === 1"><i class="el-icon-timer"></i>
              <CountDown1
                v-on:start_callback="countDownS_cb(1)"
                v-on:end_callback="countDownE_cb(1)"
                :currentTime="goods.endTimes"
                :startTime=goods.endTimes
                :endTime=goods.startTimes
                :dayTxt="'天'"
                :hourTxt="'小时'"
                :minutesTxt="'分钟'"
                :secondsTxt="'秒'" style="display: inline-block;">
              </CountDown1>
            </span>
            <span v-if="goods.transactionStatus === 2"><i class="el-icon-timer"></i>
              <CountDown1
                v-on:start_callback="countDownS_cb(1)"
                v-on:end_callback="countDownE_cb(1)"
                :currentTime="goods.startTimes"
                :startTime=goods.endTimes
                :endTime=goods.startTimes
                :dayTxt="'天'"
                :hourTxt="'小时'"
                :minutesTxt="'分钟'"
                :secondsTxt="'秒'" style="display: inline-block;">
              </CountDown1>
            </span>
            <span style="top: 17px;position: relative;" v-show="goods.transactionStatus === 3"><i class="el-icon-timer"></i>{{goods.endTime}}</span>
          </div>
          <div style="margin-left: 10px;color:grey;margin-top: -20px;">
            <sapn style="font-size: 14px;">起拍价:</sapn>
            <span style="font-size: 18px;color:#BA0000;">￥</span>
            <span style="color: #BA0000;font-size: 30px;font-weight:bold;">1111</span>
            <!-- {{goods.startPrice}} -->
            <div class="dian">哪家旗舰店</div>
            <div class="guanzu">
              <img style="position: relative;top:3.2px;left: 10px;" src="../assets/aixin.png">
              <span style="position: relative;left: 12px;">关注</span>
            </div>
            <div style="float: right;margin-right:20px;font-size: 14px;margin-top: 4px;">竞买 1000+</div>
            <!-- <div style="width: 285px;float: left;">{{goods.transactionAddress}}</div> -->
            <!-- <img class="huo" src="../assets/huo.png">
            <div style="width: 70px;float: right;">111</div> -->
          </div>
      </div>
    </div>
    <!-- 分页 -->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[12, 18, 24, 30]"
      :page-size="12"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total" style="margin:10px auto;float:left;width:100%;text-align: center;">
    </el-pagination>
      <el-row>
        <el-col :span="8"><div>
            <div style="width: 40%;height: 200px;margin-left: 10%;float: left;">
              <img style="float: left;margin-top: 37px;" src="https://img.axureshop.com/5f/7a/2f/5f7a2fd7263e4e95897c8cd096b23108/images/%E9%A6%96%E9%A1%B5/u561.svg">
              <div style="float: left;margin-left: 10px;font-size: 18px;margin-top: 50px;">微信服务号</div>
              <span style="float: left;margin-left: 10px;margin-top:30px;font-size: 14px;">一手消息随时掌握</span>
            </div>
          </div></el-col>
        <el-col :span="8"><div>
          <div style="width: 40%;height: 200px;float: left;margin-left: 10%;">
            <img style="float: left;margin-top: 37px;" src="https://img.axureshop.com/5f/7a/2f/5f7a2fd7263e4e95897c8cd096b23108/images/%E9%A6%96%E9%A1%B5/u564.svg">
            <div style="float: left;margin-left: 10px;font-size: 18px;margin-top: 50px;">微信小程序</div>
            <span style="margin-left: -87px;margin-top: 100px;float: left;font-size: 14px;">随时随地交易</span>
          </div>
        </div></el-col>
        <el-col :span="8"><div>
          <p style="margin-top: 47px;">
            <span style="margin-right: 50px;font-size: 14px;">沪ICP备XXXXXXXX号</span>
            <span style="margin-right: 50px;font-size: 14px;">增值电信业务经营许可证沪B</span>
            <span style="font-size: 14px;">全国免费服务热线：400-886-0000</span>
          </p>
          <p style="margin-top: 30px;">
            <span style="margin-right: 50px;font-size: 14px;">沪ICP备XXXXXXXX号</span>
            <span style="font-size: 14px;">增值电信业务经营许可证沪B</span>
          </p>
        </div></el-col>
      </el-row>
    </div>
</template>
<script>
import CountDown1 from 'vue2-countdown'
export default {
  components: {
    CountDown1
  },
  data () {
    return {
      phone: '', // 手机号
      dialogVisible1: false, // 登录后点击免费委托出现的弹窗
      dialogVisible: false, // 登录前点击免费委托出现的弹窗
      form: {},
      currentPage4: 1, // 分页显示第几页
      pageRequest: { // 分页请求参数
        pageSize: 12, // 每页条数
        pageNum: 1 // 每页数量
      },
      total: 0, // 分页总条数
      goodsList: {
        currentTime: 0,
        startTimes: 0, // 开始时间
        endTimes: 0 // 结束时间
      }, // 竞品列表
      imgIdList: [309, 309, 309, 309]
    }
  },
  async mounted () {
    this.selectGoodsList() // 查询竞品信息列表
    this.getUserInfoByToken() // 根据token查询用户信息
  },
  methods: {
    // 根据token查询用户信息
    getUserInfoByToken () {
      const a = sessionStorage.getItem('token')
      this.$axios.get('announcement/getUserInfoByToken', { params: { token: a } }).then((res) => {
        if (res.data.code === '200') {
          sessionStorage.setItem('userInfo', JSON.stringify(res.data.obj))
        }
      })
    },
    // 跳转至竞买
    toNoBiddingDetailsPage (goods) {
      this.$router.push({
        path: '/bidView',
        query: { goods: goods }
      })
    },
    async selectGoodsList () { // 查询竞品信息列表
      this.$axios.get('client/auction/getGoodsList', { params: { pageSize: this.pageRequest.pageSize, pageNum: this.pageRequest.pageNum } }).then((res) => {
        if (res.data.code === '200') {
          this.goodsList = res.data.obj.list
          this.total = res.data.obj.total
          for (let i = 0; i < this.goodsList.length; i++) {
            this.goodsList[i].imgId = this.goodsList[i].imgId.split(',')[0]
            if (this.goodsList[i].transactionStatus === 1) {
              this.goodsList[i].startTimes = parseInt(new Date(this.goodsList[i].startTime).getTime() / 1000)
              this.goodsList[i].endTimes = parseInt(new Date().getTime() / 1000)
            } else if (this.goodsList[i].transactionStatus === 2) {
              this.goodsList[i].startTimes = parseInt(new Date().getTime() / 1000)
              this.goodsList[i].endTimes = parseInt(new Date(this.goodsList[i].endTime).getTime() / 1000)
            }
          }
        }
      })
    },
    countDownS_cb: function (x) { // 开始倒计时进行的回调
      // console.log(x, '开始')
    },
    countDownE_cb: function (x) { // 倒计时结束进行的回调
      // this.$message.error("考试时间到，试卷自动提交");
      // console.log(x, '结束')
      this.selectGoodsList()
    },
    free_commission () { // 免费委托弹窗方法
    // 手机格式验证
      const regMobile = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
      if (this.phone !== '' && regMobile.test(this.phone)) {
        this.dialogVisible1 = true
      } else {
        this.myMessage('warning', '手机号为空或手机号格式不正确')
      }
    },
    handleSizeChange (val) { // 改变每页条数
      this.pageRequest.pageSize = val
      this.selectGoodsList()
    },
    handleCurrentChange (val) { // 改变当前页
      this.pageRequest.pageNum = val
      this.selectGoodsList()
    },
    myMessage (type, message) {
      this.$message({
        message: message,
        type: type
      })
    }
  }
}
</script>
<style lang="less" scoped>
  .dian:hover{
    color: #7DB8EB;
  }
  .dian{
    font-size: 14px;
    color:grey;
    margin-bottom: 15px;
    margin-top: 10px;
  }
  .guanzu:hover{
    border: 1px solid #BA0000;
  }
  .guanzu{
    width: 60px;
    height:25px;
    border:1px solid grey;
    font-size:12px;
    line-height:25px;
    float: left;
  }
  .sousuo{
    position: relative;
    left: 434.5px;
    top: -550px;
    float: left;
    background-color: rgba(0, 0, 0, 0.55);
    width: 1042px;
    text-align: center;
    height: 300px;
    box-shadow: 0px 0px 13px 0px rgb(0 0 0 / 14%);
    text-align: center;
  }
  .QR_code_two{
    float: left;
    width: 50%;
    height: 200px;
  }
  .QR_code_one{
    float: left;
    width: 50%;
    height: 200px;
  }
  .QR_code{
    margin-top: 20px;
    float: left;
    width: 100%;
    height: 240px;
  }
  .flow_path_three_head_sculpture{
    border-width: 0px;
    position: relative;
    left: 85px;
    top: -117px;
    width: 80px;
    height: 80px;
  }
  .flow_path_three_img{
    margin-left: 50px;
    margin-top: 78px;
    width: 150px;
    height: 150px;
  }
  .flow_path_two_weituo{
    color: grey;
    margin-left: 40px;
    margin-top: 70px;
    width: 800px;
    height: 100px;
  }
  .flow_path_two_address{
    float:left;
    margin-left: 30px;
    width: 50px;
    height: 63px;
    line-height: 63px;
  }
  .flow_path_two_phone{
    float:left;
    margin-left: 40px;
    width: 544px;
    height: 63px;
    background: inherit;
    background-color: rgba(255, 255, 255, 1);
    box-sizing: border-box;
    border-width: 1px;
    border-style: solid;
    border-color: rgba(204, 204, 204, 1);
    border-radius: 7px;
    box-shadow: none;
  }
  .flow_path_img{
    margin-top: 20px;
    margin-left: 50px;
    width: 100px;
    height: 100px;
  }
  .flow_path_two_p{
    font-size: 20px;
    margin-top: 25px;
    margin-left: 60px;
  }
  .flow_path_p{
    font-size: 20px;
    margin-top: 25px;
    margin-left: 40px;
  }
  .flow_path_three{
    float: left;
    height: 300px;
    width: 250px;
  }
  .flow_path_two{
    float: left;
    height: 300px;
    width: 900px;
  }
  .flow_path_one{
    float: left;
    height: 300px;
    width: 700px;
  }
  .flow_path{
    margin-top: 10px;
    width: 100%;
    height: 300px;
    background-color: #fff;
  }
  .huo{
    margin-top: 1px;
    width: 20px;
  }
  /* .begin_in_a_minute4{
    float: left;
    width: 100px;
    text-align: center;
    height: 33px;
    background-color: #999999;
    line-height: 33px;
  }
  .begin_in_a_minute3{
    float: left;
    width: 100px;
    text-align: center;
    height: 33px;
    background-color: #FF6633;
    line-height: 33px;
  }
  .begin_in_a_minute2{
    float: left;
    width: 100px;
    text-align: center;
    height: 33px;
    background-color: #6699CC;
    line-height: 33px;
  } */
  /* .begin_in_a_minute{
    float: left;
    width: 100px;
    text-align: center;
    height: 33px;
    background-color: #008000;
    line-height: 33px;
  } */
  .img{
    scale: 0.8;
  }
  .div1{
    float: left;
    margin:10px 10px;
    background-color: #fff;
    width: 288px;
    height: 370px;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.2);
  }
  .div1:hover{
    transform: scale(1.1);
    transition: 1s;
    border: 3px solid #BA0000;
  }
  .hot_material_transaction{
    height: 975px;
    margin-top: 10px;
    width: 100%;
    background-color: #fff;
  }
  .el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 150px;
    margin: 0;
  }
  .el-carousel__item:nth-child(2n) {
     background-color: #99a9bf;
  }
  .el-carousel__item:nth-child(2n+1) {
     background-color: #d3dce6;
  }
</style>
